const {
  appointmentDesc_mock
} = require("../../../../mock/appointment.js")
const {
  houseDesc_mock
} = require("../../../../mock/house.js")
const {
  baseUrl,
  getRequest,
  postRequest
} = require("../../../../utils/request.js")
Page({

  /**
   * 页面的初始数据
   */
  data: {
    //预约id
    appointmentId: '',
    //预约详情
    appointmentDesc: '',
    //房源详情
    houseDesc: '',
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad(options) {
    console.log(options.id)
    this.setData({ //模拟数据
      appointmentId:options.id
      //appointmentDesc: appointmentDesc_mock,
      //houseDesc: houseDesc_mock
    })
    this.http_appointment_findById()
  },

  /**
   * 返回上个页面
   */
  toLastPage() {
    wx.navigateBack();
    console.log("返回上个页面")
  },
   /**
   * 跳转到小区详情页面
   */
  onPlotPage(e) {
    wx.navigateTo({
      url: '/pages/house/plot/plot?housePlotId=' + e.currentTarget.dataset.houseplotid,
    })
  },
  /**
   * 复制电话
   */
  onPhone() {
    //const contentToCopy = this.data.houseDesc.houseBroker.houseBrokerPhone;
    const contentToCopy = "15083344188";
    wx.setClipboardData({
      data: contentToCopy,
      success: function (res) {
        wx.showToast({
          title: '复制电话成功',
        });
      },
      fail: function (res) {
        wx.showToast({
          title: '复制失败',
          icon: 'none',
        });
      }
    });
  },
  /**
   * 复制微信
   */
  onWX() {
    //const contentToCopy = this.data.houseDesc.houseBroker.houseBrokerWX;
    const contentToCopy = "wx_text";
    wx.setClipboardData({
      data: contentToCopy,
      success: function (res) {
        wx.showToast({
          title: '复制微信成功',
        });
      },
      fail: function (res) {
        wx.showToast({
          title: '复制失败',
          icon: 'none',
        });
      }
    });
  },
  /**
   * 根据id查询预约
   */
  http_appointment_findById(){
    getRequest(baseUrl+"/front/appointment/findById",{
      appointmentId:this.data.appointmentId
    }).then(res=>{
      if(res.code==200){
        this.setData({
          appointmentDesc:res.data,
          houseDesc:res.data.house
        })
      }
    })
  },
})